selectedNode = {};
YUI().use("node", function(Y) {
  Y.all('.node').on('click', function(e) {
    var node = e.currentTarget;
    Y.all('.node').setStyle('color', '#FFF');
    node.setStyle('color', 'orange');
    node.addClass("selected");
  });

});

/**
 * Draggable Area
 */
YUI().use('dd','graphics', function(Y) {
  var dragable = new Y.DD.Drag({
    node: '.node'
  }).plug(Y.Plugin.DDConstrained, {
    constrain2node: '#graphPool'
  });

  var delegate = new Y.DD.Delegate({
    container: '#graphPool',
    nodes: 'div'
  });

  delegate.dd.plug(Y.Plugin.DDConstrained, {
    constrain2node: '#graphPool'
  });




});


/**
 * Events
 */
YUI().use('node', function(Y) {

  Y.one('#addNodeButton').on('click', function(e) {
    var graphPool = Y.one('#graphPool');
    i = 5;
    var elem = graphPool.append('<div id= "node- #' + i + '" class="node"><span>test</span></div>');
  });
  Y.one('#deleteNodeButton').on('click', function(e) {
    var graphPool = Y.one('#graphPool');
    graphPool.one('.selected').remove();
  });
});